<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        .box{
            width:300px;
            margin:0 auto;
        }
        button{
            width:300px;
            text-align: center;
            height:50px;
            line-height:50px;
        }
        img{
            width:300px;  
        }
    </style>
</head>
<body>
    <div class="box">
        <button>隐藏</button>
        <img src="1.jpg" alt="" id="imgbox">
    </div>
    <script>
        var buttonbox=document.getElementsByTagName("button");
        var imgbox=document.getElementById("imgbox");

        buttonbox[0].onclick=function(){
            if(buttonbox[0].innerHTML=="隐藏"){
                buttonbox[0].innerHTML="显示";
                imgbox.style.display="none";
            }else{
                buttonbox[0].innerHTML="隐藏";
                imgbox.style.display="block";
            }
        }
    </script>
</body>
</html>